#ifndef _RETRO_LUAINTERFACE
#define _RETRO_LUAINTERFACE

#include <lua/lua.hpp>

namespace Retro
{
  namespace Scripting
  {
    class DLLEXPORT LuaInterface : public ScriptInterface
    {
    private:
      lua_State*    mLuaState;
      UINT          mPushCount;
      INT           mLuaHandler;
      PTSTR         mErrorMsg;

      static  INT   LuaCallback(lua_State *L);
      static  INT   LuaHandler(lua_State *L);

      virtual VOID  doCall();

    public:
      virtual VOID  add(ScriptValue* iValue);
      virtual VOID  add(ScriptValue* iValues, UINT iCount, PCSTR iName);

      virtual VOID  push(PVOID iValue, ValueType iType);
      virtual VOID  push(ScriptValue* iValues, UINT iCount);
      virtual VOID  get(UINT iIndex, PVOID oValue, ValueType iType);

      virtual INT   getParamCount();
      virtual ValueType getType(UINT iIndex);

      virtual PCTSTR getErrorMessage();

      virtual BOOL  run(PCSTR iScript);
      virtual BOOL  call(PCSTR iName);
      virtual BOOL  validate(PCSTR iScript);

      LuaInterface();
      ~LuaInterface();
    };
  } // namespace Scripting
} // namespace Retro
#endif
